package com.ktwlsoft.archivemanage.domain.business.repositoryService.view;

import com.ktwlsoft.archivemanage.domain.dao.repository.view.UnitArchiveReportMapper;
import com.ktwlsoft.archivemanage.payload.view.TransferStatistic;
import lombok.Getter;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.Year;

@Service
public class TransferDataProfileRepositoryService {

    @Getter
    private final UnitArchiveReportMapper unitArchiveReportMapper;

    public TransferDataProfileRepositoryService(UnitArchiveReportMapper unitArchiveReportMapper) {
        this.unitArchiveReportMapper = unitArchiveReportMapper;
    }

    @Transactional(rollbackFor = Exception.class)
    public TransferStatistic getProgressStatistic(Year year) {
        Long transferCount = unitArchiveReportMapper.findTotalTransferCount(year);
        Long transferUnitCount = unitArchiveReportMapper.findTransferUnitCount(year);
        Long waitTransferCount = unitArchiveReportMapper.findWaitTransferCount(year);
        return new TransferStatistic(transferCount, transferUnitCount, waitTransferCount);
    }
}
